package net.huanger.gametools.mapeditor.model;


import java.io.File;
import java.io.Serializable;
import java.util.Arrays;


public class MapModel implements Serializable
{
  private static final long serialVersionUID = 1L;

  private int row, column;

  private int[][] titeData;

  public MapModel(int row, int column)
  {
    super();
    this.row = row;
    this.column = column;
    this.titeData = new int[row][column];
  }

  public int getTite(int r, int c)
  {
    return titeData[r][c];
  }

  public void setTite(int r, int c, int tite)
  {
    this.titeData[r][c] = tite;
  }

  public void setTite(int cell, int tite)
  {
    int r = cell / column;
    int c = cell % column;
    this.titeData[r][c] = tite;
  }

  public int getRow()
  {
    return row;
  }

  public void setRow(int row)
  {
    this.row = row;
  }

  public int getColumn()
  {
    return column;
  }

  public void setColumn(int column)
  {
    this.column = column;
  }

  public int[][] getTiteData()
  {
    return titeData;
  }

  public void exportMap(File f)
  {
    System.out.printf("[row=%d,column=%d]\n", row, column);
    for(int[] arr:getTiteData()){
      System.out.println(Arrays.toString(arr));
    }
  }
}
